package homework;


import java.util.Scanner;

public class RefArrayDemo {
    public static void main(String[] args) {
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑",2,"黑");
        dogs[1] = new Dog("小白",1,"白");
        dogs[2] = new Dog("小灰",3,"灰");
        for (int i = 0; i < dogs.length; i++) {
            System.out.println(dogs[i].name);
            dogs[i].swim();
            dogs[i].eat();
            dogs[i].lookHome();
        }

        Chick[] chicks = new Chick[3];
        chicks[0] = new Chick("小黄",1,"黄");
        chicks[1] = new Chick("小红",2,"红");
        chicks[2] = new Chick("小紫",3,"紫");
        for (int i = 0; i < chicks.length; i++) {
            System.out.println(chicks[i].name);
            chicks[i].eat();
            chicks[i].drink();
            chicks[i].layEggs();
        }


        Fish[] fishes = new Fish[3];
        for (int i = 0; i < fishes.length; i++) {
            fishes[i] = setFish();
            System.out.println("小鱼"+fishes[i].name+"已完成设置！");
            fishes[i].eat();
            fishes[i].drink();
        }


    }

    public static Fish setFish(){
        Scanner sc = new Scanner(System.in);
        System.out.println("小鱼的名字：");
        String name = sc.next();
        System.out.println("小鱼的年龄：");
        int age = sc.nextInt();
        System.out.println("小鱼的颜色：");
        String color = sc.next();
        Fish fish = new Fish(name,age,color);
        return fish;
    }
}
